﻿using Microsoft.Data.SqlClient;
using Microsoft.EntityFrameworkCore;
using System;
using System.Linq;


namespace ConsoleAppEfCore
{
    class Program
    {
        static void Main(string[] args)
        {
            using (EfTestDbContext dbContext = new EfTestDbContext())
            {
                if (!dbContext.Persons.Any(x => x.Name.Contains("lei")))
                {
                    dbContext.Persons.Add(new Person()
                    {
                        Age = 33,
                        Name = "lei yang"
                    });
                    dbContext.SaveChanges();
                }
                Console.WriteLine(dbContext.Persons.Count());
            }
            Console.WriteLine("Hello World!");
        }
    }
}
